import unittest
from matrix import Matrix


class MyTestCase(unittest.TestCase):
    def test_something(self):
        matrix = Matrix(3, 4, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14])
        self.assertEqual(3, matrix.row_count)
        self.assertEqual(4, matrix.col_count)
        self.assertSequenceEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12], list(matrix.plain()))

        trans = matrix.transposed()
        self.assertEqual(4, trans.row_count)
        self.assertEqual(3, trans.col_count)
        self.assertSequenceEqual([1, 5, 9, 2, 6, 10, 3, 7, 11, 4, 8, 12], list(trans.plain()))

        prod = matrix * 2
        self.assertEqual(3, prod.row_count)
        self.assertEqual(4, prod.col_count)
        self.assertSequenceEqual([2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24], list(prod.plain()))

        prod2 = matrix * trans
        self.assertEqual(3, prod2.row_count)
        self.assertEqual(3, prod2.col_count)
        self.assertSequenceEqual([30, 70, 110, 70, 174, 278, 110, 278, 446], list(prod2.plain()))

        self.assertSequenceEqual(
            [220, 280, 490, 640],
            list((Matrix(2, 3, [1, 2, 3, 4, 5, 6]) * Matrix(3, 2, [10, 20, 30, 40, 50, 60])).plain())
        )


if __name__ == '__main__':
    unittest.main()
